Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases related to JWT authentication. #2179

Merged
merged 4 commits into from
Nov 10, 2022

Conversation

lukasz-soszynski-eliatra
Copy link
Contributor

Signed-off-by: Lukasz Soszynski [email protected]

Description

[Describe what this change achieves]

  • Category (Integration tests)
  • Why these changes are required?
  • What is the old behavior before changes and new behavior after changes?

New integration tests which check if JWT authentication works correctly.

Issues Resolved

[List any issues this PR will resolve]

Is this a backport? If so, please add backport PR # and/or commits #

Testing

[Please provide details of testing done: unit testing, integration testing and manual testing]

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@lukasz-soszynski-eliatra lukasz-soszynski-eliatra requested a review from a team October 19, 2022 14:51
Copy link
Member

@peternied peternied left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking for a little more testing depth - is that possible with jwt error responses or another system?

@lukasz-soszynski-eliatra lukasz-soszynski-eliatra force-pushed the jwt-authentication branch 3 times, most recently from c6c6dd1 to 00cafad Compare October 24, 2022 11:33
peternied
peternied previously approved these changes Oct 24, 2022
Copy link
Contributor

@stephen-crawford stephen-crawford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@stephen-crawford stephen-crawford self-requested a review October 25, 2022 16:46
cwperks
cwperks previously approved these changes Nov 2, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 2, 2022

Codecov Report

Merging #2179 (397b730) into main (40e2e9c) will decrease coverage by 0.04%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##               main    #2179      +/-   ##
============================================
- Coverage     61.05%   61.01%   -0.05%     
+ Complexity     3269     3267       -2     
============================================
  Files           259      259              
  Lines         18337    18337              
  Branches       3248     3248              
============================================
- Hits          11196    11188       -8     
- Misses         5555     5559       +4     
- Partials       1586     1590       +4     
Impacted Files Coverage Δ
...ecurity/configuration/StaticResourceException.java 0.00% <0.00%> (-25.00%) ⬇️
...urity/ssl/transport/SecuritySSLNettyTransport.java 62.36% <0.00%> (-4.31%) ⬇️
...nsearch/security/dlic/rest/api/AuditApiAction.java 63.82% <0.00%> (-4.26%) ⬇️
...earch/security/ssl/util/SSLConnectionTestUtil.java 93.18% <0.00%> (-2.28%) ⬇️
.../dlic/auth/ldap2/LDAPConnectionFactoryFactory.java 57.46% <0.00%> (-1.50%) ⬇️
...ecurity/configuration/ConfigurationRepository.java 74.31% <0.00%> (+2.18%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@DarshitChanpura DarshitChanpura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty @lukasz-soszynski-eliatra . Added a few comments

this.headerName = requireNonNull(headerName, "Header name is required");
}

Header validToken(String username, String...roles) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This method generates a validToken correct? If so can you please rename it as such?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the methods below as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected.

import static org.opensearch.test.framework.log.LogCapturingAppender.PLUGIN_NAME;

@Plugin(name = PLUGIN_NAME, category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE, printObject = true)
public class LogCapturingAppender extends AbstractAppender {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a brief javadoc of why this class is need or what does it do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also same for the class below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@DarshitChanpura
Copy link
Member

Bwc tests are broken on main. Tracking issue here: #2221

@cwperks
Copy link
Member

cwperks commented Nov 10, 2022

@lukasz-soszynski-eliatra Looks like there is a spotbugs issue on this PR. Can you address the issue?

Task :spotbugsIntegrationTest FAILED
  org.opensearch.security.action.configupdate.ConfigUpdateAction
H I Dm: Found reliance on default encoding in org.opensearch.security.http.JwtAuthenticationTests.<static initializer for JwtAuthenticationTests>(): new String(byte[])  At JwtAuthenticationTests.java:[line 92]

@lukasz-soszynski-eliatra
Copy link
Contributor Author

Thanks, now it should work better.

@peternied
Copy link
Member

@opensearch-project/security This change blocking some of the other test PRs, can we get another review on this change?

@cwperks
Copy link
Member

cwperks commented Nov 10, 2022

@peternied All checks succeeded except for the BWCTests which is a known sequencing issue. Can this be merged?

@peternied peternied merged commit 977677d into opensearch-project:main Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants